**
**  Political Economy of Consumer Debt Relief
**
**  Code for CRRC-Survey Analysis
**
**  July 2024
**  

clear all
cd  "/Users/zas/Library/CloudStorage/Dropbox/Vote Buying_shared/Georgia/!REStat/Replication"
use "survey.dta"

** Debt relief variables from CRRC-barometer-survey

gen     debt_relief = "No one" if BENFDEBY==-5
replace debt_relief = "Me" if BENFDEBY==1
replace debt_relief = "My family" if BENFDEBF ==1
replace debt_relief = "My acquaintance" if BENFDEBA ==1
label var debt_relief "Do you know someone who benefited from debt relief program?"

gen 	debt_me = "Other"
replace debt_me = "I benefited" if BENFDEBY==1
replace debt_me = "my family benefited" if BENFDEBF==1

gen 	debt_us = 0
foreach x in BENFDEBY BENFDEBF {
replace debt_us = 1 if `x'==1
replace debt_us = . if `x'==-1 | `x'==-2
}
label var debt_us "Either I and/or my family benefited from debt relief program"

gen     debt_salience = 0 if FEELDEBR!=-2
replace debt_salience = 1 if FEELDEBR==-5
label var debt_salience "I have not heard about the debt relief program"

gen     debt_pos = 1 if FEELDEBR==4 | FEELDEBR==3
replace debt_pos = 0 if FEELDEBR==2 | FEELDEBR==1
label var debt_pos "I feel positively or very positively about the debt relief program"


** Political attitudes variables

gen     VOTLEL = "Never" if VOTLEL1==0 & VOTLEL2==0
replace VOTLEL = "Yes I, Not II" if VOTLEL1==1 & VOTLEL2==0
replace VOTLEL = "Not I, Yes II" if VOTLEL1==0 & VOTLEL2==1
replace VOTLEL = "Both" if VOTLEL1==1 & VOTLEL2==1
encode VOTLEL, gen(vote_turnout)
label var vote_turnout "Did you vote in the 2018 presidential elections"

gen     party = "UNM" if PARTYSUPP==302
replace party = "Georgian Dream" if PARTYSUPP==301
replace party = "No Party" if PARTYSUPP==-5
replace party = "Other Party" if PARTYSUPP>302 & PARTYSUPP<=999

gen     party_gd = 0 if party!=""
replace party_gd = 1 if PARTYSUPP==301
label var party_gd "The political party closest to me is Georgian Dream"
gen     party_unm = 0 if party!=""
replace party_unm = 1 if PARTYSUPP==302
label var party_unm "The political party closest to me is United National Movement"

gen     trust_pres = 1 if TRUPRES==4 | TRUPRES==5
replace trust_pres = 0 if TRUPRES==3 | TRUPRES==2 | TRUPRES==1
label var trust_pres "I rather or fully trust the president"

gen     elections_fair = 1 if ELCOND==3
replace elections_fair = 0 if ELCOND==2 | ELCOND==1
label var elections_fair "The 2018 presidential elections were conducted completely fairly"

** Socio-demographic variables

replace RESPSEX = 0 if RESPSEX==2
label var RESPSEX "female or male"
label var  RESPAGE  "age"
label var  EDUYRS  "years of education"
replace  RESPEMP =. if  RESPEMP ==-3
label var  RESPEMP  "employed or not"


***
*** Results Political Attitudes (Within Survey)

** TABLE 3

local controls RESPSEX RESPAGE EDUYRS RESPEMP 

foreach y in party_gd party_unm trust_pres elections_fair {
foreach x in debt_salience debt_pos debt_us {
reg `y' `x' `controls'
outreg2 using results/survey_t3, label e(F) ctitle() cttop() tex(frag) dec(4) excel drop() sortvar(debt_salience debt_pos debt_us RESPSEX RESPAGE EDUYRS RESPEMP) append
}
}

***
*** Results Validation (Survey vs Debt Relief Data)

** Merge with treatment intensity data on district and precinct levels

tostring PSU, gen(PSU_str)
gen district_no = substr(PSU_str,-5,2)
destring district_no, replace
gen precinct_no = substr(PSU_str,-5,5)
destring precinct_no, replace

merge m:1 precinct_no using "auxiliary_data/treatment_intensity_precincts.dta"
rename _merge merge_p
merge m:1 district_no using "auxiliary_data/treatment_intensity_districts.dta"
rename _merge merge_d

** TABLE 2

local controls RESPSEX RESPAGE EDUYRS RESPEMP 

foreach y in debt_salience debt_pos debt_us {
foreach x in p_debt_tot_ln p_debt_tot_ln0  {
*foreach x in d_debt_tot_ln d_id_no_ln  p_debt_tot_ln p_id_no_ln  p_debt_tot_ln0 p_id_no_ln0 {
reg `y' `x' `controls'
outreg2 using results/survey_t2, label e(F) ctitle() cttop() tex(frag) dec(4) excel drop() sortvar(d_debt_tot_ln d_id_no_ln  p_debt_tot_ln p_id_no_ln  p_debt_tot_ln0 p_id_no_ln0 debt_salience debt_pos debt_us RESPSEX RESPAGE EDUYRS RESPEMP ) append
}
}

** TABLE C7 (Robustness of Table 2 on validation exercise with different treatments) 

* Panel A: treatments at precinct level without 0s

foreach y in debt_salience debt_pos debt_us {
foreach x in  p_id_no_ln  p_id_no_ln0{
reg `y' `x' `controls'
outreg2 using results/survey_t2_robust_ind, label e(F) ctitle() cttop() tex(frag) dec(4) excel drop() sortvar( p_debt_tot_ln p_id_no_ln  p_debt_tot_ln0 p_id_no_ln0 d_debt_tot_ln d_id_no_ln  debt_salience debt_pos debt_us RESPSEX RESPAGE EDUYRS RESPEMP ) append
}
}

* Panel B: treatments at district level

foreach y in debt_salience debt_pos debt_us {
foreach x in  d_debt_tot_ln d_id_no_ln  {
reg `y' `x' `controls'
outreg2 using results/survey_t2_robust_dist, label e(F) ctitle() cttop() tex(frag) dec(4) excel drop() sortvar( p_debt_tot_ln p_id_no_ln  p_debt_tot_ln0 p_id_no_ln0 d_debt_tot_ln d_id_no_ln  debt_salience debt_pos debt_us RESPSEX RESPAGE EDUYRS RESPEMP ) append
}
}
